<template>
	<view class="baseView">
		<u-input
			type="text"
			:border="true"
			borderColor="#72a3ff"
			placeholder="请输入用户名"
			v-model="username"
			style="margin: 16rpx; margin-top: 32rpx;"
		></u-input>

		<u-input
			v-model="password"
			type="password"
			:border="true"
			borderColor="#72a3ff"
			placeholder="请输入密码"
			style="margin: 16rpx;"
		></u-input>
		<u-button type="success" style="align-self: center;margin-top: 16rpx;" @click="doLogin()">登录</u-button>
	</view>
</template>

<script>
export default {
	data() {
		return {
			username: '',
			password: '',
		};
	},
	computed: {
		testCompute: function() {
			return this.num;
		}
	},
	methods: {
		doLogin() {
			this.$u.api.doLogin({ username: this.username, password: this.password }).then(res => {
				if (Object.is(res.code, 200)) {
					getApp().globalData.isLogin = true;
					getApp().globalData.token = res.token;
					uni.switchTab({
						url: '../homepage/homepage'
					});
				}
			});
		}
	}
};
</script>

<style></style>
